package com.hrp.controller;

import com.hrp.service.PowerServiceClinet;
import com.hrp.utill.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * MySpringCloud
 *
 * @Title: com.hrp.controller
 * @Date: 2020/5/23 17:44
 * @Author: wfg
 * @Description:
 * @Version:
 */
@RestController
public class UserController {

    @Autowired
    private RestTemplate restTemplate;
    private static final String POWER_URL="http://SERVER-POWER";
    private static final String ORDER_URL="http://SERVER-ORDER";

    @Autowired
    private PowerServiceClinet powerServiceClinet;

    @RequestMapping("/getPower4Feign.do")
    public R getPower4Feign(){
        return R.success("操作成功",powerServiceClinet.getPower());
    }
    @RequestMapping("/getUser.do")
    public R getUser(){
        return R.success().set("user","zhangsan");
    }

    @RequestMapping("/getPower.do")
    public R getPower(){
        return R.success("操作成功",restTemplate.getForObject(POWER_URL+"/getPower.do",Object.class));
    }

    @RequestMapping("/getOrder.do")
    public R getOrder(){
        return R.success("操作成功",restTemplate.getForObject(ORDER_URL+"/getOrder.do",Object.class));
    }
//    @RequestMapping("/getPower.do")
//    public R getPower(){
//        return R.success("操作成功",restTemplate.getForObject("http://localhost:8081/getPower.do",Object.class));
//    }

}
